package com.common.library.ui.view.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import java.util.Arrays;
import java.util.List;

/**
 * @author txf
 * @Title 常见的FragmentPagerAdapter 适配器
 * @package com.zhsj.tvbee.android.ui.adapter
 * @date 2016/9/9 0009
 * @note Updatey by Chaosxing on 2016/10/18
 */
public class SimpleFragmentAdapter extends FragmentPagerAdapter {
    List<String> titles;
    List<Fragment> fragments;
    public SimpleFragmentAdapter(FragmentManager fm, List<Fragment> fragments) {
        super(fm);
        this.fragments = fragments;
    }
    public SimpleFragmentAdapter(FragmentManager fm, List<String> titles, List<Fragment> fragments) {
        super(fm);
        this.titles = titles;
        this.fragments = fragments;
    }
    public SimpleFragmentAdapter(FragmentManager fm, String[] titles, Fragment[] fragments) {
        super(fm);
        this.titles = Arrays.asList(titles);
        this.fragments = Arrays.asList(fragments);
    }
    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }
    @Override
    public int getCount() {
        return fragments == null ? 0 : fragments.size();
    }
}
